<?php

class Benservi_Log_Log{

    public function init(){}

     static public function factory($msg, $priority, $controller)
     {

        $usuario = Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session("default"))->getStorage()->read();       
        
        $db = Zend_Db_Table::getDefaultAdapter();
        $columnMapping = array("nivel" => "nivel", "msg" => "message", "controller" => "controller", "usuario" => "usuario");
        $writer = new Zend_Log_Writer_Db($db, "log", $columnMapping);
        $logger = new Zend_Log($writer);

        $logger->setEventItem("controller", $controller);
        $logger->setEventItem("usuario", $usuario->nome);
        $logger->setEventItem("nivel", $priority);
        $logger->setEventItem("horario", date("Y/mm/dd H:m:s"));
        $logger->info($msg, $priority);

        $logger = null;
     }
}

?>
